

import {
  INCREMENTCOUNT,
  DECREMENTCOUNT
} from '../constant/countConst'

import store from '../store'

//累加的Action
export const increamentAction = (data=1)=>{
 return {
    type: INCREMENTCOUNT,
    data
  }
 }
//累减的Action
 export const decreamentAction = (data=1)=>{
  return {
    type: DECREMENTCOUNT,
    data
  }
 }
 //异步的Action
 /* 
  Actions must be plain objects. Instead, the actual type was: 'number'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.
  Action必须是返回一个对象 不能是一个函数 提示 用 thunk中间件将函数变成对象
 */
 export const waitcreamentAction = (data=1)=>{
  return ()=>{
    setTimeout(()=>{
      store.dispatch({
        type: INCREMENTCOUNT,
        data
      })
    },2000)
  }
 }